package hu.diploma.web.server.serviceimpl;

import hu.diploma.common.service.EmailService;
import hu.diploma.common.vos.EmailVo;
import hu.diploma.core.util.ServiceProviderImpl;
import hu.diploma.web.client.service.WebEmailService;
import hu.diploma.web.shared.webvos.EmailWebVo;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class WebEmailServiceImpl extends RemoteServiceServlet implements WebEmailService {

	EmailService emailService = ServiceProviderImpl.getServiceProvider().getEmailService();

	public List<EmailWebVo> loadall() throws Exception {
		List<EmailWebVo> emailWebVos = new ArrayList<EmailWebVo>();

		List<EmailVo> emailVos = emailService.loadAll();
		for (EmailVo emailVo : emailVos) {
			EmailWebVo emailWebVo = new EmailWebVo();
			emailWebVo.setDate(emailVo.getDate());
			emailWebVo.setFrom(emailVo.getFrom());
			emailWebVo.setSubject(emailVo.getSubject());
			emailWebVos.add(emailWebVo);
		}
		return emailWebVos;
	}

}
